package com.itbaizhan.web;

import com.itbaizhan.pojo.Items;
import com.itbaizhan.pojo.Orders;
import com.itbaizhan.pojo.Users;
import com.itbaizhan.service.UsersService;
import com.itbaizhan.service.impl.UsersServiceImpl;

import java.util.List;

/*关联对象测试*/
public class Test04 {
    public static void main(String[] args) {
        UsersService us = new UsersServiceImpl();
        Users users = us.findUsers(1);
        System.out.println("users:"+users.getUserid()+" "+users.getUsername()+" "+users.getUserage());
        //一个用户有多个订单
         List<Orders> orders = users.getOrders();
         for(Orders o:orders){
             System.out.println("Orders:"+o.getOrderid()+" "+o.getOrderprice());
             //商品在订单里，一个订单里面有多个商品
             List<Items> items = o.getItems();
             for (Items i:items){
                 System.out.println("Items:"+i.getItemid()+" "+i.getItemname()+" "+i.getIremprice()+" "+i.getIntemnum());
             }

         }
    }
}
